@extends('www/zc-admin/layout')
@section('content')

<div class="main-container">

    @include("/www/zc-admin/left-nav",['typeId'=>$typeId,'nav'=>'refund'])



    <div class="main-content">

        <div class="content-anv">
            <span>首页</span>
            <span> ></span>
            <span>总凑总览</span>

            <ul>
                <li><span>众筹中：</span><span class="num">{{$total - $finish}}</span></li>
                <li><span>已完成：</span><span class="num">{{$finish}}</span></li>
                <li><span>总计：</span><span class="num">{{$total}}</span></li>
            </ul>
        </div>


        <form action="?typeId={{$typeId}}" class="seach-box" method="get">
            <input type="hidden" name="typeId" value="{{$typeId}}" id="typeId">
            <?php  $status = Request::input('status',-1);?>

          
            <span class="btn btn-danger" onclick="refund()">退款</span>

            <select name="sort">
                @if(Request::input('sort') =='money')
                    <option value="time">订单最新排序</option>
                    <option value="money" selected>金额由高到低</option>
                @else
                    <option value="time" selected>订单最新排序</option>
                    <option value="money">金额由高到低</option>
                @endif
            </select>

            <select name="activityId" id="activityId">
                <option value="0">选择活动</option>
                @foreach($activitys as $act)
                    <option value="{{$act->activity_id}}" @if($act->activity_id == Request::input('activityId')) selected @endif >{{$act->title}}</option>
                @endforeach
            </select>

         

            <input type="text" name="title"  id="title" placeholder="请输入标题" value="{{Request::input('title','')}}">
            <input type="text" name="wxname" id="wxname" placeholder="请输入微信名称" value="{{Request::input('wxname','')}}">
            <input type="text" name="mobile" id="mobile" placeholder="请输入手机号" value="{{Request::input('mobile','')}}">

            
            
            <p><img src="/www/zc666/images/admin/seach.png" onclick="$('form').submit();"></p>
        </form>

    
        <table class="table">
            <tr>
                <th>ID</th>
                <th>标题</th>
                <th>微信号</th>
                <th>姓名</th>
                <th>电话</th>
                <th>筹款金额</th>
                <th>已筹金额</th>
                
                <th>操作</th>
            </tr>

            @foreach($orders as $order)
                <tr>
                    <td>{{$order->id}}</td>
                    <td>{{$order->title}}</td>
                    <td>{{$order->wx_name}}</td>
                    <td>{{$order->real_name}}</td>
                    <td>{{$order->mobile}}</td>
                    <td>{{$order->money}}</td>
                    <td>{{$order->raised_money}}</td>
                    

                    

                    
                    <td>
                        @if($order->refunded_at == null)

                            未退款
                            <!-- <a href="/www/zhongchouAdmin/hand_order?orderId={{$order->id}}" class="btn btn-danger" onclick="return confirm('确定？');">退款
                            </a> -->

                        @else
                            <p>已退款</p>
                        @endif
                    </td>
                </tr>
            @endforeach
        </table>

    
        <div style="margin-bottom:80px;">
            {{ $orders->appends(Request::all())->links() }}
        </div>
    </div>
</div>

<div id="showrefund" style="position:fixed;height:100vh;width:100vw;background:rgba(0,0,0,.7);z-index:1000;line-height:100vh;text-align:center;color:#fff;font-size:50px;top:0;display:none;">正在退款 。。。。。。</div>
<script>
    

function refund()
{

    if(!confirm("点击搜索查询您退款的订单，此步骤危险，谨慎操作,确认退款吗?"))
    {

        return;
    }
    var data = {
        typeId:$('#typeId').val(),
        activityId:$('#activityId').val(),
        title:$('#title').val(),
        wxname:$('#wxname').val(),
        mobile:$('#mobile').val()
    };

    $('#showrefund').show();

    $.ajax({
        url:"/www/zhongchouAdmin/refund",
        data:data,
        type:'get',
        success:function(res){


            if(res.code == 200)
            {
                alert('已退款');
                
                location.reload();

            }

        }
    })
}

</script>

@endsection